<?php

namespace App;

use App\Model\Photo;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Passport\HasApiTokens;

class User extends Authenticatable
{
    use HasApiTokens,Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $dates = ['deleted_at'];
    protected $primaryKey = 'user_id';
    protected $hidden = ['password', 'remember_token']; // select 时不显示
    //protected $visible = ['user_id', 'weixin_user_id', 'full_name', 'avatar', 'authorArticles', 'createdArticles', 'updatedArticles'];
    protected $fillable = [
        'name', // 昵称
        'serial_number', // 序号
        'employee_id', // 工号
        'email',
        'remember_token',
        'full_name',
        'pinyin',
        'first_letter',
        'sex',
        'weixin_id',
        'weixin_user_id', // 企业微信账号, 唯一标识符: 与企业微信同步 !
        'avatar',
        'mobile',
        'position',
        'birthday',
        'address',
        'QQ',
        'phone2',
        'entry_date',
        'id_card',
        'enable', // 启用/禁用成员。1表示启用成员，0表示禁用成员
        'status', // 激活状态: 1=已激活，2=已禁用，4=未激活 已激活代表已激活企业微信或已关注微信插件。未激活代表既未激活企业微信又未关注微信插件。
        'wxplugin_status', // 关注微信插件的状态: 1=已关注，0=未关注
        'isleader', // 是否上级
        'qualify_date',
        'contract_with',
        'contract_period',
        'contract_sign',
        'contract_expire',
        'social_security',
        'disabled_at',
        'created_by',
        'updated_by',
    ];
    public static $sexArr = [ 'Secret', 'Male', 'Female',];
    public static $sexArrWx = [ 'Secret'=>'0', 'Male'=>'1', 'Female'=>'2',]; // moa -> wechat
    public static $statusArr = [ 0=>'未知', 1=>'已激活', 2=>'已禁用', 4=>'未激活',];
    public static $colsList = ['users.user_id', 'users.name', 'users.serial_number', 'users.employee_id', 'users.email', 'users.full_name','users.avatar','users.enable','users.status','users.wxplugin_status','users.weixin_user_id', 'users.position', 'users.isleader', 'users.mobile',];
    protected $appends = [ ];
    protected static $recordEvents = ['updated', 'deleting'];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
//    protected $hidden = [
////        'password', 'remember_token',
////    ];
///
    //照片
    public function photos(){
        return $this->belongsToMany(Photo::class,'user_photo','user_id','photo_id');
    }
}
